#!/usr/bin/env perl
use warnings;
use strict;

# Precomputed files (see definitions in Makefile).
my $sim_size = 17770;
my $sim = "bellkor_pearson.similarity.bin";
my $coratings = "movie_coratings.bin";

# For removing temporary files.
sub clean {
  print "CLEAN_FILES += ".join(" ",@_)."\n";
}

# Compute term weights using movies with at least k ratings.
my @term_weights = ();
sub term_weights {
  my ($terms, $d, $beta) = @_;
  my $t = "";
  if ($terms =~ /one_to_(\d+)/) {
    $t = "one_to_$1\_";
  }
  my $out = $t."d$d\_beta$beta.term_weights";
  print <<STR;
$out: $sim $coratings $terms
\tbin/term_weights $sim_size $sim $coratings $d $beta <$terms >$out
STR
  push @term_weights, $out;
}

my @termss = ("big.one_to_1.new.links_by_movie",
  "big.one_to_2.new.links_by_movie");
my @ds = (10,50,500); # Page shrinkage factors.
my @betas = (500,50000); # Ratings shrinkage factors
for my $terms (@termss) {
  for my $d (@ds) {
    for my $beta (@betas) {
      term_weights($terms,$d,$beta);
    }
  }
}

# Rules to make results.
print "term_weights: ".join(" ", @term_weights)."\n";

# Copyright (c) 2009 John Lees-Miller
# 
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

